﻿// javascript for admin page
jQuery(document).ready(function () {
    // enable tooltip
    vtip();

    // toggle admin dropdown menu
    $("#a-systembar li").click(function () {
        $(this).find("ul").toggle();
    }).hover(null, function () {
        $(this).find("ul").css("display", "none");
    });

    // confirmation on logout
    $("#a-systembar .a-logout a").click(function () {
        if (!confirm('Are you sure you want to logout?'))
            return false;
    });

    $.fn.activeMenu = function (activeClass) {
        var loc = location.href;
        $(this).find('a').each(function () {
            var href = $(this).attr('href');
            if (loc.search(href) != -1) {
                $(this).parent().addClass(activeClass);
                $(this).parent('li').parent('ul').parent('li').addClass(activeClass);
                return;
            }
        });
    }

    // active current item in navigations
    // tabs menu in main page
    $("#main-page-nav").activeMenu('ui-state-active');

    // collapse Ticket Filters
    $("#ticket_filter_collapse_button").click(function () {
        $("#tabs_ticket_panel").addClass("expanded");
        $("#left_tabs_ticket_panel").hide();
        $("#right_tabs_ticket_panel").animate({ left: "0" }, 250, function () {
            $(".ticket_filter_expand_button").show();
            $("#ticket_filter_grouping_div").addClass("ticket_filter_grouping_div_centered");
        });
        $("#ticket_filter_items_manage_menu").animate({ left: "0" }, 250);
    });

    // expand Ticket Filters
    $("#ticket_filter_expand_button").click(function () {
        $("#tabs_ticket_panel").removeClass("expanded");
        $("#right_tabs_ticket_panel").animate({ left: "286px" }, 250, function () {
            $("#left_tabs_ticket_panel").show();
            $(".ticket_filter_expand_button").hide();
            $("#ticket_filter_grouping_div").removeClass("ticket_filter_grouping_div_centered");
        });
        $("#ticket_filter_items_manage_menu").animate({ left: "286px" }, 250)
    });
});